home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Collections: MegaDisc
/
MegaDisc 36 (1993-11)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).zip
/
MegaDisc 36 (1993-11)(MegaDisc Digital Publishing)(AU)(Disk 2 of 2).adf
/
ARexx
/
Chars
/
CharsDemo
< prev
next >
Wrap
Text File
|
1993-09-17
|
4KB
|
124 lines
/* Defined Characters Demo */
/* By John Collett */
lib.1 = 'rexxsupport.library' ; lib.2 = 'rexxarplib.library'
do i = 1 to 2
if ~show('l',lib.i) then check = addlib(lib.i,0,-30,0)
end
address AREXX '"call CreateHost(HO, PORT)"'
if ~show('Ports','HO') then address command 'WaitForPort HO'
flags = 'WINDOWCLOSE+WINDOWDRAG+WINDOWDEPTH'
idcmp = 'CLOSEWINDOW'
call OpenWindow(HO,50,20,550,180,idcmp,flags,'Character Displayer')
call openport(PORT) ; call ActivateWindow(HO)
fileopen = 0 ; call CharFile()
if ~(fileopen) then signal 'finish'
t=time('r') ; call Apen(1)
call pat(16,24,'The following lines contain user-defined characters:')
call APen(2)
t = 'Examples of Greek characters are {alpha} and {beta}.'
call Chart(16,40,t) ; call Apen(1)
t = "In maths you may have used {pi} and {chi}."
call Chart(16,55,t) ; call Apen(2)
t = "The International Phonetics Alphabet, not hard to learn, uses"
call pat(16,70,t)
t = "symbols (enclosed in square brackets) to show pronunciation."
call pat(16,80,t)
t = "The French for 'cat' is 'chat', pronounced [{sh}{ah}]."
call Chart(16,90,t)
call Apen(1) ; t = "Adjacent characters can work together : "
t = t || "{zed1}{zed2}" ; call Chart(16,110,t)
t = time('r') ; call Apen(2)
call pat(46,130,'This screen took ' || t || ' seconds to process.')
call Apen(1)
t = 'If you need to use many special characters, then another'
call pat(46,140,t)
t = 'approach such as brush images may be better. For occasional'
call pat(46,150,t)
t = 'needs, the method you have seen here may be adequate.'
call pat(46,160,t)
do forever
call waitpkt(PORT) ; p = getpkt(PORT)
if p ~== NULL() then
do
i = getarg(p) ; t = reply(p, 0)
parse var i class
if i = 'CLOSEWINDOW' then signal 'finish'
end
end
finish:
if fileopen then cl = close(cf)
call CloseWindow(HO)
exit
/* F u n c t i o n s */
pat:
if arg() = 4 then call APen(arg(4))
call Move(HO,arg(1),arg(2)) ; call Text(HO,arg(3))
return
APen: call SetAPen(HO,arg(1)) ; return
CharFile:
if ~fileopen then do
charfil = GetFile(160,30,,'chars','Character defs file')
if charfil ~= '' then do
if exists(charfil) then do
op = open(cf,charfil,'r') ; fileopen = 1 ; end
else req = Request(160,30,'Character file not found',,'Okay')
end
return
Chart:
x = arg(1) ; y = arg(2) ; txt = arg(3)
lastchar = (right(txt,1) = '}') /* See note below */
/* The following few lines replace '{ }'s with spaces, and return
the contents of '{ }'s as array elements */
newtxt = '' ; n = 0
do until txt = ''
n = n + 1
parse var txt t1 '{' txt ; parse var txt t2 '}' txt
newtxt = newtxt || t1 || ' ' ; label.n = t2
pos.n = length(newtxt) - 1
end
/* The next line is a fix for when the last part of the whole line is
not within braces. This had me puzzled for a while, but the fix works.
*/
if ~ lastchar then n = n - 1
call pat(x,y,strip(newtxt)) ; y = y - 7
do la = 1 to n
p = seek(cf,0,'b') ; found = 0
do until found | eof(cf)
t = readln(cf) ; parse var t lab ',' parms .
found = (lab = label.la)
end
col = x + pos.la * 8
parse var parms a.1 ',' a.2 ',' a.3 ',' a.4 ',' a.5 ',',
a.6 ',' a.7 ',' a.8 .
do j = 1 to 8
if a.j = 0 then iterate /* All bits are zero ; no shading in */
row = y + j
/* Convert eight stored numbers to 1's and 0's */
octet = c2b(d2c(a.j))
do bit = 1 to 8
/* Shade in the bits which are a 1 */
if substr(octet,bit,1) then do
call Move(HO,col+bit,row); call Draw(HO,col+bit,row); end
end
end
end
return
/* E n d */